<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <div id="app">
      <h1>{{msg}}</h1>
      <com-a @handler='getData'></com-a>
  </div>

  <template id="tmp">
    <div>
       <h1>{{msg}}</h1>
       <button @click='send'>click</button>
    </div>
</template>
  <script src="./vue.js"></script>
  <script>
      const comA = {
          data() {
              return {
                  msg:"子组件的msg"
              }
          },
          methods:{
            send() {
                this.$emit("handler",this.msg)
            }
          },
          template:"#tmp"
      }

    var vm = new Vue({
      el:'#app',
      data:{
          msg:"父组件的msg: "
      },
     components:{
         comA
     },
     methods:{
        getData(res) {
            console.log(res);
            this.msg += res
        }
     }
     });
  </script>
</body>
</html>
